473,468 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Make DropDownList fire a clientside Javascript function?

Hi all,

In ASP.NET 2.0 and VB.NET, I am trying to get the OnSelectedIndexChanged
event to fire a Javascript function. There is no OnClientClick event for
that control.

When I try something like:
OnSelectedIndexChanged="javascript:SetOwner('<%= lstOwner.ClientID %>');" I
get an error.

Whereas for a simple HTML anchor I can do:
<a href="javascript:show_calendar('aspnetForm.txtUpda te');"
without a problem.

Any ideas?

TIA
Dec 12 '07 #1
2 10704
John,

I think you're looking for the javascript "onchange" event (which runs in
the browser) not the OnSelectedIndexChanged event (which runs on the
server). Also, don't be afraid to post a little more code! ;)

Scott
"John Kotuby" <Jo********@discussions.microsoft.comwrote in message
news:Ot**************@TK2MSFTNGP06.phx.gbl...
Hi all,

In ASP.NET 2.0 and VB.NET, I am trying to get the OnSelectedIndexChanged
event to fire a Javascript function. There is no OnClientClick event for
that control.

When I try something like:
OnSelectedIndexChanged="javascript:SetOwner('<%= lstOwner.ClientID %>');"
I get an error.

Whereas for a simple HTML anchor I can do:
<a href="javascript:show_calendar('aspnetForm.txtUpda te');"
without a problem.

Any ideas?

TIA
Dec 12 '07 #2
Thanks again Scott,

Sometimes I lose sight of the fact that ASP.NET is simply generating HTML
and I should break out the HTML books to look for the correct clientside
event for the corresponding HTML tags that are rendered and to append the
event to a server control that does not natively support that event. I am
beginning to see the value of custom Server controls that inherit from the
base controls and have developer-added functionality.

Of course, some of the clientside Javascript that ASP.NET generates is
highly inscrutable.

"Scott Roberts" <sr******@no.spam.here-webworks-software.comwrote in
message news:ev**************@TK2MSFTNGP04.phx.gbl...
John,

I think you're looking for the javascript "onchange" event (which runs in
the browser) not the OnSelectedIndexChanged event (which runs on the
server). Also, don't be afraid to post a little more code! ;)

Scott
"John Kotuby" <Jo********@discussions.microsoft.comwrote in message
news:Ot**************@TK2MSFTNGP06.phx.gbl...
>Hi all,

In ASP.NET 2.0 and VB.NET, I am trying to get the OnSelectedIndexChanged
event to fire a Javascript function. There is no OnClientClick event for
that control.

When I try something like:
OnSelectedIndexChanged="javascript:SetOwner('<% = lstOwner.ClientID %>');"
I get an error.

Whereas for a simple HTML anchor I can do:
<a href="javascript:show_calendar('aspnetForm.txtUpda te');"
without a problem.

Any ideas?

TIA

Dec 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Federico Moschini [328594] | last post by:
I have to make difference between2 data from a table in SQL. The page is made with Frontpage, and it extracts QtaGiaCons and Quantita from table "oclrighe". I have to make Quantita -...
2
by: MBhat | last post by:
Hello, I have a dropdownlist server control.On selectedIndexChange I do some functionality. In addtion to this I need to check for something else. To do this I have to use javascript function to...
7
by: Daniel | last post by:
Is there any other way can override this event, like javascript onchange added to the attribute of this dropdownlist? Thanks
1
by: Urmal Patel via .NET 247 | last post by:
I have problem with asp:Dropdownlist. I have a dropdownlist control in Page1.aspx and I want to assign value and Text to dropdown list form Page2.aspx from java script function. I am able to assign...
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
3
by: RFS666 | last post by:
Hello together, I tried to find out about populating an asp.net server control (a dropdownlist) from the clientside jscript, but I didn't find a solution up to now. I cannot use a html...
4
by: David | last post by:
Hi all, I am doing this in a web page... I have a dropdownlist that autopostback. This sets me a filter criteria for items to display in a datalist. In the datalist, I have edit...
3
by: Iain | last post by:
Hi All I have 2 DropDownList boxes on a page. The first (id= "Operation") is populated on PageLoad with the contents of a database table. The second id="WorkStations" will not be populated...
2
by: Yi | last post by:
I want to make a simple javascript widget, something looks like the Google AdWords, that people can just post a small section of code on their web page and display some content from my website. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.